//
// Created by liushuai on 2020/3/18.
//
#include "isPalindrome.h"
bool isPalindrome(ListNode* head){
    bool result = true;
    if(!head)
        return result;
    ListNode* fast = head;
    ListNode* slow = head;
    while(fast&&fast->next){
        fast = fast->next->next;
        slow = slow->next;
    }
    ListNode* reverse = reverseLinklist(slow);
    while(reverse){
        if(reverse->val != head->val){
            result = false;
            break;
        }
        reverse = reverse->next;
        head = head->next;
    }
    return result;
}

